<html>
<head>
    <style>
        span{
            display: block;
            width: 10px;
            height: 10px;
            border: 1px red solid;
        }

    </style>
</head>
<body>
<script>
    window.sessionStorage.setItem("openId","abc");
    var openId = window.sessionStorage.getItem("openId");
    console.log(openId + "============");       //abc============

    function a() {
        window.location.href = 'http://www.baidu.com';
    }

    var str="How are you doing today?";

    document.write(str.split(" ") + "<br />");
    var a = str.split(" ");     //返回数组，以空格分割
    console.log(a[0]);  //返回第一个元素       How
    console.log(a.length);  //数组长度          5
    console.log(a[0].length);  //字符串长度      3


    var a = function (parameter) {
        if (typeof (parameter) == "undefined" || parameter == "") {
            return null;
        }
        var url = "http://wx.readerday.com/auth.html";
        var index = url.indexOf("?");
        console.log(index);         //-1
        if (index != -1) {
            var parameterString = url.substr(index + 1);
            var reg = new RegExp("(^|&)" + parameter + "=([^&]*)(&|$)", "i");
            var r = parameterString.match(reg);
            if (r != null) {
                return r[2];
            }
        }
        return null;
    }
    console.log(a("url"));      //null

    console.log("=================================");
    var shareUrl = "https://merchant.readerday.com/index_fxs.html?ADTAG=wx.readerday.com&code=20";
    var splitCode = "?code".indexOf(window.location.href)==-1 ? "&code" : "?code";
    console.log(splitCode);         //&code
    console.log(shareUrl.split(splitCode)[0]);      //https://merchant.readerday.com/index_fxs.html?ADTAG=wx.readerday.com

    console.log(encodeURIComponent((shareUrl.split(splitCode)[0])));    //https%3A%2F%2Fmerchant.readerday.com%2Findex_fxs.html%3FADTAG%3Dwx.readerday.com
    console.log(encodeURIComponent((shareUrl.split(splitCode)[0])).length-4);   //76
    console.log(encodeURIComponent(shareUrl.split(splitCode)[0]).substring(encodeURIComponent(shareUrl.split(splitCode)[0]).length-4) + "+++++++++++++");//.com+++++++++++++
    if(encodeURIComponent(window.location.href.split(splitCode)[0]).substring(encodeURIComponent(window.location.href.split(splitCode)[0]).length-4)=='html'){
        relink = shareUrl + "auth.html?url="+encodeURIComponent(window.location.href.split(splitCode)[0]+'?appid=' + Cappid);
        console.log(relink);
    }else {
        relink = shareUrl + "auth.html?url="+encodeURIComponent(window.location.href.split(splitCode)[0]+'&appid=' + Cappid);
        console.log(relink);
    }


    //alert(typeof(a)); //判断类型
</script>
<h2>Hello World!</h2>
<span id="a" onclick="a();"></span>     <%--点击跳转页面--%>


</body>
</html>
